﻿using System;
using System.Web;
using Orchard.DisplayManagement.Implementation;
using Orchard.Environment.Extensions;

namespace Mod.CookieDetector
{
    public class Shapes : IShapeFactoryEvents
    {
        public void Created(ShapeCreatedContext context)
        {
        }

        public void Creating(ShapeCreatingContext context)
        {
        }

        public static bool IsLogOn(ShapeCreatedContext context)
        {
            return context.ShapeType == "LogOn" || context.ShapeType == "ModLogOn" || context.ShapeType == "LoginShape";
        }
    }

    public class CookieShape : IShapeFactoryEvents
    {
        public void Creating(ShapeCreatingContext context)
        {
        }

        public void Created(ShapeCreatedContext context)
        {
            if (Mod.CookieDetector.Shapes.IsLogOn(context))
            {
                context.Shape.Metadata.Wrappers.Add("Wrappers_Cookie_LogOn");
            }
        }
    }
}